package HuaWeiOd.AA;

import java.util.Scanner;

/**
 * @author caihe
 * @date 2023/4/13 9:46
 */
public class 箱子之形摆放 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] arr = sc.nextLine().split(" ");

        String a = arr[0];
        Integer b = Integer.parseInt(arr[1]);

        for (int i = 0; i < b; i++) {
            int index = i;
            // 关键---------------------
            int step = 2 * (b - i) - 1;
            
            int n = 0;
            while (index < a.length()) {
                System.out.print(a.charAt(index));
                if (n % 2 == 0) {
                    index += step;
                } else {
                    index += 2 * b - step;
                }
                n++;
            }
            System.out.println();
        }
    }
}
//0 5 6 11
//1 4 7 10
//2 3 8 9

// 5 
// 3
// 1

// ABCDEFG 3
